home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln1286.arc
/
BNCHMARK.ADA
/
SIEVE.ADA
< prev
Wrap
Text File
|
1986-10-21
|
1KB
|
51 lines
with TEXT_IO; use TEXT_IO;
procedure SIEVE is
--
-- Sieve of Eratosthenes
-- Source available from Mark Petersen's Alpo-Net FIDO board at
-- (619) 741-3412, 300/1200/2400 8,N,1
--
size : constant integer := 8192;
count : long_integer;
flags : array (0..size) of boolean;
k : natural;
prime : natural;
begin
--
-- Compute a table of the first n prime numbers.
--
count := 0;
--
-- Do it 10 times
--
for j in 1..10 loop
for i in 0..size loop
flags(i) := TRUE;
end loop;
for i in 0..size loop
if flags(i) then
prime := i + i + 3;
k := i + prime;
while k <= size loop
flags(k) := FALSE;
k := k + prime;
end loop;
count := count + 1;
end if;
end loop;
end loop;
put_line(long_integer'image(count) & " primes");
end SIEVE;